//index.js
Page({
  data: {
    imgUrls: [
      '../../image/b1.png',
      '../../image/b2.png'
    ],
    indicatorDots: true,
    indicatorColor: "#969696",
    indicatorActiveColor: "#3975e2",
    vertical: false,
    autoplay: false,
    interval: 2000,
    duration: 500,
    navlist: [
      {
        id: 'nav0',
        name: '财经快讯',
        img: '../../image/icon/1.png',
        url: 'smallLoan/smallLoan'
      },
      {
        id: 'nav1',
        name: '财经大咖',
        img: '../../image/icon/2.png',
        url: 'smallLoan/smallLoan'
      },
      {
        id: 'nav2',
        name: '金融峰会',
        img: '../../image/icon/3.png',
        url: 'smallLoan/smallLoan'
      },
      {
        id: 'nav3',
        name: '实时要闻',
        img: '../../image/icon/4.png',
        url: 'smallLoan/smallLoan'
      }
      // {
      //   id: 'nav0',
      //   name: '小微贷款',
      //   img: '../../image/icon-main1.png',
      //   url: 'smallLoan/smallLoan'
      // }, {
      //   id: 'nav1',
      //   name: '汽车金融',
      //   img: '../../image/icon-main2.png',
      //   url: 'carService/carService'
      // }, {
      //   id: 'nav2',
      //   name: '信用卡服务',
      //   img: '../../image/icon-main3.png',
      //   url: 'creditCard/creditCard'
      // }, {
      //   id: 'nav3',
      //   name: '记账工具',
      //   img: '../../image/icon-main4.png'
      // }, {
      //   id: 'nav4',
      //   name: '企业租赁',
      //   img: '../../image/icon-main5.png'
      // }, {
      //   id: 'nav5',
      //   name: '项目融资',
      //   img: '../../image/icon-main6.png'
      // }, {
      //   id: 'nav6',
      //   name: '线下金融',
      //   img: '../../image/icon-main7.png',
      //   url: 'underLine/underLine'
      // }, {
      //   id: 'nav7',
      //   name: '其他应用',
      //   img: '../../image/icon-main-more.png'
      // }
    ],
    list: [
      {
        id: '0',
        name: '互联网流量',
        text: '流量用户批发',
        img: '../../image/icon-service1.png',
        page: ''
      }, {
        id: '1',
        name: '利息计算器',
        text: '算一算付多少',
        img: '../../image/icon-service2.png',
        page: 'calculator'
      }, {
        id: '2',
        name: '资质牌照',
        text: '代售代买合作',
        img: '../../image/icon-service3.png',
        page: 'license'
      }
    ]
  },
  onLoad: function () {
    var that = this;
    wx.request({
      url: 'https://dk.9ok.xin/qbhz_app_xcx.json',
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        that.setData({
          navlist: res.data
        })
      }
    })
  },
  navToggle: function (e) {
    var id = e.currentTarget.id,list = this.data.navlist;
    for (var i = 0, len = list.length; i < len; ++i) {
      if (list[i].id == id) {
        if (list[i].url && list[i].flag) {
          wx.navigateTo({
            url: 'pages/' + list[i].url + '?flag=' + list[i].flag
          })
          return
        }
        if (list[i].url) {
          wx.navigateTo({
            url: 'pages/' + list[i].url
          })
          return
        }
      }
    }
  }
})
